home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 2010 April / PCWorld0410.iso / hity wydania / Ubuntu 9.10 PL / karmelkowy-koliberek-desktop-9.10-i386-PL.iso / casper / filesystem.squashfs / usr / lib / linux-boot-probes / mounted / 40grub next >
Text File  |  2009-09-21  |  2KB  |  104 lines

  1. #!/bin/sh
  2. . /usr/share/os-prober/common.sh
  3. set -e
  4.  
  5. partition="$1"
  6. bootpart="$2"
  7. mpoint="$3"
  8. type="$4"
  9.  
  10. found_item=0
  11.  
  12. entry_result () {
  13.     if [ "$ignore_item" = 0 ] && \
  14.        [ -n "$kernel" ] && \
  15.        [ -e "$mpoint/$kernel" ]; then
  16.         result "$rootpart:$bootpart:$title:$kernel:$initrd:$parameters"
  17.         found_item=1
  18.     fi
  19.     kernel=""
  20.     parameters=""
  21.     initrd=""
  22.     title=""
  23.     ignore_item=0
  24. }
  25.  
  26. parse_grub_menu () {
  27.     mpoint="$1"
  28.     rootpart="$2"
  29.     bootpart="$3"
  30.     
  31.     kernel=""
  32.     parameters=""
  33.     initrd=""
  34.     title=""
  35.     ignore_item=0
  36.  
  37.     while read line; do
  38.         #debug "parsing: $line"
  39.         set -- $line
  40.         case "$1" in
  41.             title)
  42.                 entry_result
  43.                 shift 1
  44.                 title="$(echo $@ | sed 's/://g')"
  45.                 if echo "$title" | grep -q '(on /dev/[^)]*)$'; then
  46.                     log "Skipping entry '$title':"
  47.                     log "appears to be an automatic reference taken from another menu.lst"
  48.                     ignore_item=1
  49.                 fi
  50.             ;;
  51.             kernel)
  52.                 # Hack alert: sed off any (hdn,n) but
  53.                 # assume the kernel is on the same
  54.                 # partition.
  55.                 kernel="$(echo $2 | sed 's/(.*)//')"
  56.                 shift 2
  57.                 parameters="$@"
  58.                 # Systems with a separate /boot will not have
  59.                 # the path to the kernel in menu.lst.
  60.                 if [ "$partition" != "$bootpart" ]; then
  61.                     kernel="/boot$kernel"
  62.                 fi
  63.             ;;
  64.             initrd)
  65.                 initrd="$2"
  66.                 # Initrd same.
  67.                 if [ "$partition" != "$bootpart" ]; then
  68.                     initrd="/boot$initrd"
  69.                 fi
  70.             ;;
  71.             boot)
  72.                 entry_result
  73.             ;;
  74.             module)
  75.                 log "Skipping entry '$title':"
  76.                 log "parsing of entries containing 'module' lines is currently not supported"
  77.                 ignore_item=1
  78.             ;;
  79.         esac
  80.     done
  81.  
  82.     entry_result
  83. }
  84.  
  85. grubconf=
  86. if [ -e "$mpoint/boot/grub/menu.lst" ]; then
  87.     grubconf="menu.lst"
  88. elif [ -e "$mpoint/boot/grub/grub.conf" ]; then
  89.     grubconf="grub.conf"
  90. fi
  91.  
  92. if [ "$grubconf" ] && \
  93.    ([ ! -e "$mpoint/boot/grub/grub.cfg" ] || \
  94.     [ "$mpoint/boot/grub/$grubconf" -nt "$mpoint/boot/grub/grub.cfg" ]); then
  95.     debug "parsing $grubconf"
  96.     parse_grub_menu "$mpoint" "$partition" "$bootpart" < "$mpoint/boot/grub/$grubconf"
  97. fi
  98.  
  99. if [ "$found_item" = 0 ]; then
  100.     exit 1
  101. else
  102.     exit 0
  103. fi
  104.